package com.up1234567.unistarcloud.demo.web.task;

import com.up1234567.unistar.springcloud.task.IUnistarTasker;
import com.up1234567.unistarcloud.demo.web.WebConfig;
import lombok.CustomLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;

@CustomLog(topic = "WebTasker")
@Component
public class DayChangeTask implements IUnistarTasker {

    @Autowired
    private WebConfig webConfig;

    @PostConstruct
    public void init() {
        log.info("testenc={}", webConfig.getEnc());
        log.info("testimp={}", webConfig.getImp());
    }

    @Override
    public String task() {
        return "day_change";
    }

    @Override
    public Map<String, Object> handle(Map<String, Object> params) {
        if (params == null) params = new HashMap<>();
        params.put("title", "day_change");
        params.put("testimp", webConfig.getImp());
        return params;
    }

}
